<?php

use Biz\service\bizActivity\mjKitchenHome;
use Doraemon\tools\Log;

class DeliveryAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

//    const VALIDATOR_TOAST_DEBUG = true;

//    //参数校验-规则
//    const VALIDATOR_RULES = [
//        'winning_record_id' => 'require|integer',
//        'name' => 'require',
//        'phone' => 'require',
//    ];
//
//    //参数校验-自定义消息
//    const VALIDATOR_MSG = [
//        'winning_record_id.require' => '参数错误',
//        'name.require' => '请输入姓名',
//        'phone.require' => '请输入手机号',
//    ];

    public function main()
    {
        $post = $this->getRequest()->getPost();
        $query = $this->getRequest()->getQuery();
        $this->params = $post ?: $query;
        $id = $this->params['winning_record_id'] ?? 0;
        $name = $this->params['name'];
        $phone = $this->params['phone'];
        $address = $this->params['address'] ?? '';

        mjKitchenHome::setDelivery($this->uid, $name, $phone, $address, $id);
        Log::info('setDelivery', compact('name', 'phone', 'address', 'id', 'post', 'query') + ['cookie' => $_COOKIE['openid']]);
        $this->setSuccess('success');
    }
}